﻿using System;
using System.Linq;
using FirstFloor.Documents;

namespace SampleBrowser.Util
{
    /// <summary>
    /// A custom filter limiting the visible pages to the first 4 and last 4 pages of any document.
    /// </summary>
    public class CustomPageFilter
        : IPageFilter
    {
        /// <summary>
        /// Determines whether specified page is visible.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <returns>
        /// 	<c>true</c> if is page visible; otherwise, <c>false</c>.
        /// </returns>
        public bool IsPageVisible(PageContent page)
        {
            return page.PageNumber < 5 || page.PageNumber > page.Document.Pages.Count() - 4;
        }
    }
}
